<template>
  <div class="app-container">
    <wms-form v-model:query-params="queryParams" :form-list="formList" @query="getList" label-width="88px"
      @export="handleExport">

    </wms-form>

    <wms-table :loading="loading" :data-list="supplierList" :column="column" :pageInfo="queryParams"
      @get-list="getList" />

  </div>
</template>

<script setup name="Supplier">
import {
  listSupplier,
  getSupplier,
  delSupplier,
  addSupplier,
  updateSupplier,
} from "@/api/wms/supplier";
import WmsTable from '@/components/WmsTable/index.vue'
import WmsForm from '@/components/WmsForm/index.vue'
import { data, column, formList } from './index.js'
import { ref, reactive, getCurrentInstance, onMounted } from "vue";
const { proxy } = getCurrentInstance();
const queryParams = reactive(data.queryParams);

const supplierList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
/** 查询供应商资料列表 */
function getList() {
  loading.value = true;
  listSupplier(queryParams).then((response) => {
    supplierList.value = response.rows;
    queryParams.total = response.total;
    loading.value = false;
  });
}


/** 搜索按钮操作 */
function handleQuery() {
  queryParams.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  queryParams.dateRange = [];
  proxy.resetForm("queryRef");
  handleQuery();
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "wms/supplier/export",
    {
      ...queryParams,
    },
    `supplier_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>
